package com.educate.controller;

import com.educate.common.api.Result;
import com.educate.pojo.PreProblem;
import com.educate.pojo.Problem;
import com.educate.pojo.ProblemThumbs;
import com.educate.service.ProblemService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author xiongyu
 * @date 2021/12/8 18:25
 */

@RestController
@RequestMapping("/problem")
@Slf4j
public class ProblemController {

    @Autowired
    private ProblemService problemService;

    @GetMapping("/{id}")
    public Result UserQueryProblem(@PathVariable Long id){
        return Result.success(problemService.queryProblemById(id));
    }

    @PostMapping
    public Result addProblem(@RequestBody Problem problem){
        return Result.success(problemService.addProblem(problem));
    }

    @GetMapping
    public Result queryAllProblem(){
        return Result.success(problemService.queryAllProblems());
    }

    @GetMapping("/queryHotProblems")
    public List<PreProblem> queryHotProblems(){
        return problemService.queryHotProblems();
    }


    /**
     * 通过id查询问题详情
     * @param id
     * @return
     */
    @GetMapping("queryProblem/{id}")
    public Problem queryProblem(@PathVariable Long id){
        return problemService.queryProblem(id);
    }

}
















